<%@ page language="java" import="java.util.*" contentType="text/html;charset=utf-8" pageEncoding="UTF-8"%>
<%@ taglib uri="/struts-tags" prefix="s"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<script type="text/javascript" src="<%=basePath %>js/jquery.js"></script>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<base href="<%=basePath%>">
<title>考试系统</title>
<style type="text/css">
<!--
body {
	margin-left: 3px;
	margin-top: 0px;
	margin-right: 3px;
	margin-bottom: 0px;
}
.STYLE1 {
	color: #e1e2e3;
	font-size: 12px;
}
.STYLE6 {color: #000000; font-size: 12; }
.STYLE10 {color: #000000; font-size: 12px; }
.STYLE19 {
	color: #344b50;
	font-size: 12px;
}
.STYLE21 {
	font-size: 12px;
	color: #3b6375;
}
.STYLE22 {
	font-size: 12px;
	color: #295568;
}
-->
</style>
	<script language="JavaScript">
	
	$(function(){
		  $("#showteacher").click(function (){
			if($("#teacher").css("display") == 'none'){
				$("#teacher").css("display","block");
			}
			else
				$("#teacher").css("display","none");
		  }) 
	  })
		
	  function findUser(){
		  var name = $("#username").val();
		   $.get("<%=request.getContextPath()%>/UserAction!userexit.action",{name:name}, callback);	  
	  }
	  
	  function callback(data){
		  var name = $("#username").val();
		  var arr = new Array();
		  arr = data.split("%");
		  if(arr[0]==0){
			  window.location.href="<%=request.getContextPath()%>/Admin/AdminAction!editUser.action?name="+name;
			  
		  }
		  else{
			  $("#info").text('该姓名不存在，请输入正确姓名');
		  }
	  }
	  
	  var flagname; 
	  var flagpt; 
	  function checkname(){
		  var tname = $("#teachername").val();
		  $.get("<%=request.getContextPath()%>/UserAction!userexit.action", {name:tname}, teacherCallback);
	  }
	  
	  function teacherCallback(data){
		  var arr = new Array();
		  arr = data.split("%");
		  if(arr[0]==1){                   //用户不存在，可注册
			  flag = true;
		  }
		  else{
			  flag = false;
			  $("#addteainfo").text('该用户以存在，请重新输入');
		  }
	  }
	  
	  function checkpt(){
		  var pw  = $.trim($("#password").val());
		  var tel  = $.trim($("#tel").val());
		  if(pw=="" || tel ==""){
			  flagpt=false;
			  $("#addteainfo1").text('请填写正确信息');			  
		  }	
		  else
			  flagpt=true;
	  }
	  
	  function submit(){
		  checkname();
		  checkpt;
		  if(flagname&&flagpt)
		  	$("#tea").submit();
		  
			    
	  }
	  
	  
	
	</script>
</head>
<body>

<table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td height="30"><table width="100%" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td height="24" bgcolor="#353c44"><table width="100%" border="0" cellspacing="0" cellpadding="0">
          <tr>
            <td><table width="100%" border="0" cellspacing="0" cellpadding="0">
              <tr>
                <td width="6%" height="19" valign="bottom"><div align="center"><img src="images/tb.gif" width="14" height="14" /></div></td>
                <td width="94%" valign="bottom"><span class="STYLE1"> 
                	<s:if test="flag == 'teacher'">老师列表</s:if>
                	<s:else>学生列表</s:else>    
                	</span></td>
              </tr>
            </table></td>
            <td><div align="right"></div></td>
          </tr>
        </table></td>
      </tr>
    </table></td>
  </tr>
  <tr>
    <td><table width="100%" border="0" cellpadding="0" cellspacing="1" bgcolor="#a8c7ce">
    
    <tr>

    </tr>
    
    
      <tr>
        <td width="8%" height="20" bgcolor="d3eaef" class="STYLE6"><div align="center"><span class="STYLE10">编号</span></div></td>
        <td width="14%" height="20" bgcolor="d3eaef" class="STYLE6"><div align="center"><span class="STYLE10">昵称</span></div></td>
        <td width="14%" height="20" bgcolor="d3eaef" class="STYLE6"><div align="center"><span class="STYLE10">姓名</span></div></td>
        <td width="14%" height="20" bgcolor="d3eaef" class="STYLE6"><div align="center"><span class="STYLE10">学院</span></div></td>
        <td width="12%" height="20" bgcolor="d3eaef" class="STYLE6"><div align="center"><span class="STYLE10">专业</span></div></td>
        <td width="12%" height="20" bgcolor="d3eaef" class="STYLE6"><div align="center"><span class="STYLE10">学号/工号</span></div></td>
        <td width="10%" height="20" bgcolor="d3eaef" class="STYLE6"><div align="center"><span class="STYLE10">基本操作</span></div></td>
      </tr>
      <s:iterator value="paperPage.list" id="users">
	  <tr>
        <td height="20" bgcolor="#FFFFFF" class="STYLE19"><div align="center"><s:property value="#users.id" /></div></td>
        <td height="20" bgcolor="#FFFFFF" class="STYLE19"><div align="center"><s:property value="#users.username" /></div></td>
        <td height="20" bgcolor="#FFFFFF" class="STYLE19"><div align="center"><s:property value="#users.realname" /></div></td>
        <td height="20" bgcolor="#FFFFFF" class="STYLE19"><div align="center"><s:property value="#users.college" /></div></td>
        <td height="20" bgcolor="#FFFFFF" class="STYLE19"><div align="center"><s:property value="#users.major" /></div></td>
        <td height="20" bgcolor="#FFFFFF" class="STYLE19"><div align="center"><s:property value="#users.stunum" /></div></td>		 		 
		<td height="20" bgcolor="#FFFFFF"><div align="center"><span class="STYLE21">
			     			
       			<a href="<%=path %>/Admin/AdminAction!editUser.action?id=<s:property value="#users.id" />"/>详细</a>    			
       			
		</span></div></td>
	  </tr>
	  </s:iterator>
    </table></td>
  </tr>
</table>

<s:if test="flag=='teacher'">
	
	<div id='page'>
		
    <a href="<%=request.getContextPath()%>/Admin/AdminAction!stuList.action?currentpage=1&pagesize=10">First Page</a>
    <a href="<%=request.getContextPath()%>/Admin/AdminAction!stuList.action?currentpage=${paperPage.currentpage-1}&pagesize=10&flag=teacher">Prev Page</a>
    <a href="<%=request.getContextPath()%>/Admin/AdminAction!stuList.action?currentpage=${paperPage.currentpage}&pagesize=10&flag=teacher">[${paperPage.currentpage}]</a>
    <a href="<%=request.getContextPath()%>/Admin/AdminAction!stuList.action?currentpage=${paperPage.currentpage+1}&pagesize=10&flag=teacher">[${paperPage.currentpage+1}]</a>
    <a href="<%=request.getContextPath()%>/Admin/AdminAction!stuList.action?currentpage=${paperPage.currentpage+2}&pagesize=10&flag=teacher">[${paperPage.currentpage+2}]</a>
    <a href="<%=request.getContextPath()%>/Admin/AdminAction!stuList.action?currentpage=${paperPage.currentpage+3}&pagesize=10&flag=teacher">[${paperPage.currentpage+3}]</a>
    <a href="<%=request.getContextPath()%>/Admin/AdminAction!stuList.action?currentpage=${paperPage.currentpage+1}&pagesize=10&flag=teacher">Next Page</a>
    <a href="<%=request.getContextPath()%>/Admin/AdminAction!stuList.action?currentpage=${paperPage.totalpagecount}&pagesize=10&flag=teacher">Last Page</a>
    <span>当前第${paperPage.currentpage}/${paperPage.totalpagecount}页</span>
   
</div>

</s:if>

<s:else>
	<div id='page'>
		
    <a href="<%=request.getContextPath()%>/Admin/AdminAction!stuList.action?currentpage=1&pagesize=10">First Page</a>
    <a href="<%=request.getContextPath()%>/Admin/AdminAction!stuList.action?currentpage=${paperPage.currentpage-1}&pagesize=10">Prev Page</a>
    <a href="<%=request.getContextPath()%>/Admin/AdminAction!stuList.action?currentpage=${paperPage.currentpage}&pagesize=10">[${paperPage.currentpage}]</a>
    <a href="<%=request.getContextPath()%>/Admin/AdminAction!stuList.action?currentpage=${paperPage.currentpage+1}&pagesize=10">[${paperPage.currentpage+1}]</a>
    <a href="<%=request.getContextPath()%>/Admin/AdminAction!stuList.action?currentpage=${paperPage.currentpage+2}&pagesize=10">[${paperPage.currentpage+2}]</a>
    <a href="<%=request.getContextPath()%>/Admin/AdminAction!stuList.action?currentpage=${paperPage.currentpage+3}&pagesize=10">[${paperPage.currentpage+3}]</a>
    <a href="<%=request.getContextPath()%>/Admin/AdminAction!stuList.action?currentpage=${paperPage.currentpage+1}&pagesize=10">Next Page</a>
    <a href="<%=request.getContextPath()%>/Admin/AdminAction!stuList.action?currentpage=${paperPage.totalpagecount}&pagesize=10">Last Page</a>
    <span>当前第${paperPage.currentpage}/${paperPage.totalpagecount}页</span>
   
</div>
</s:else>


<span>输入姓名查询:  <input type="text" id="username"/>  <input type="button" value="查询" onclick="findUser()"/><div id="info" style="color: red" ></div></span>


<s:if test="flag=='teacher'">   
<span id="showteacher" style="cursor:hand">点击添加老师用户</span>
<div id="teacher" style="display:none;">

<form id="tea" action="./Admin/AdminAction!addTeacher.action" method="post">
	<table width="20%" border="0" cellpadding="0" cellspacing="1" bgcolor="#a8c7ce">
		
		<tr>
			 <td width="40%" height="20" bgcolor="d3eaef" class="STYLE6"><div align="center"><span class="STYLE10">角色</span></div></td>
			 <td height="20" bgcolor="#FFFFFF" class="STYLE19"><div align="center">  <input type="text" readonly name="user.role" value="1"  style="display:none"/>
			  教师
			 </div></td>
		</tr>
		
		<tr>
			 <td width="40%" height="20" bgcolor="d3eaef" class="STYLE6"><div align="center"><span class="STYLE10">用户名</span></div></td>
			 <td height="20" bgcolor="#FFFFFF" class="STYLE19"><div align="center"><input type="text"  name="user.username" id="teachername" /></div></td>
		</tr>
		
		<tr>
			 <td width="40%" height="20" bgcolor="d3eaef" class="STYLE6"><div align="center"><span class="STYLE10">密码</span></div></td>
			 <td height="20" bgcolor="#FFFFFF" class="STYLE19"><div align="center"><input type="text" name="user.userpassword" id="password"  /> </div></td>
		</tr>
		<tr>
			 <td width="40%" height="20" bgcolor="d3eaef" class="STYLE6"><div align="center"><span class="STYLE10">电话</span></div></td>
			 <td height="20" bgcolor="#FFFFFF" class="STYLE19"><div align="center"><input type="text" name="user.tel" id="tel" /> </div></td>
		</tr>
			
		
		<tr>
			  <td height="20" bgcolor="#FFFFFF" class="STYLE19"><div align="center"> <input type="button" value="提交" onclick="submit()"></div></td>
			  <td height="20" bgcolor="#FFFFFF" class="STYLE19"><div align="center"> <input type="reset" value="重置">  </div></td>
		</tr>
		<tr><span id = "addteainfo"></span></tr>
		<tr><span id = "addteainfo1"></span></tr>
	</table>
	</form>
</div>

</s:if>
</body>
</html>
